﻿using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FurStudy.Application
{
    /// <summary>
    /// 注册泛型实例
    /// 一个接口多个实现
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBusinessService<T>
    {
        Person Get(int id);
        string GetName();
    }

    [Injection(Named = "BusName1")] // 自定义解析名称
    public class BusinessService<T> : IBusinessService<T>, ITransient
    {
        //private readonly IRepository<Person> _personRepository;

        //public BusinessService(IRepository<Person> personRepository)
        //{
        //    _personRepository = personRepository;
        //}

        //public Person Get(int id)
        //{
        //    return _personRepository.Find(id);
        //}
        public Person Get(int id)
        {
            throw new NotImplementedException();
        }

        public string GetName()
        {
            return "我是：" + nameof(BusinessService<T>);
        }
    }

    [Injection(Named = "BusName1")] // 自定义解析名称
    public class OtherBusinessService : IBusinessService<Person>, ITransient
    {
        public Person Get(int id)
        {
            throw new NotImplementedException();
        }

        public string GetName()
        {
            return "我是：" + nameof(OtherBusinessService);
        }
    }
}
